// Author: David Taubman
// All rights reserved.
// daiycheng@gmail.com.
#pragma once

#ifndef CVVIMAGE_CLASS_DEF
#define CVVIMAGE_CLASS_DEF

#include "opencv.hpp"

/* CvvImage class definition */
class  CvvImage
{
public:
	CvvImage();
	virtual ~CvvImage();

	/* Load image from specified file */
	virtual bool  Load( const char* filename, int desired_color=1 );

	/* Load rectangle from the file */
	virtual bool  LoadRect( const char* filename, int desired_color, CvRect r );

#if defined WIN32 || defined _WIN32
	virtual bool  LoadRect( const char* filename,int desired_color, RECT r )
	{
		return LoadRect( filename, desired_color,
			cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top ));
	}
#endif
	/* Save entire image to specified file. */
	virtual bool  Save( const char* filename );

	// width and height of ROI.
	int  Width();
	int  Height();
	int  Bpp();
	void GetROI(cv::Mat& roiMat, CvRect& r);
	virtual void  Fill( int elemValue );

	/* draw to highgui window */
	virtual void  Show( const char* window );

#if defined WIN32 || defined _WIN32
	/* draw part of image to the specified DC */
	virtual void  Show( HDC dc, int x, int y, int width, int height,
		int from_x = 0, int from_y = 0 );
	/* draw the current image ROI to the specified rectangle of the destination DC */
	virtual void  DrawToHDC( HDC hDCDst, RECT* pDstRect );
#endif

private:
	/* the bitmap data needs to be DWORD aligned.*/
	void AlignByte();

public:
	cv::Mat    m_image;
};

typedef CvvImage CImage;

#endif

